package com.delos.rbac.controller;

import com.delos.rbac.dto.UserDTO;
import com.delos.rbac.service.IUserService;
import com.delos.rbac.vo.UserVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 用户控制器
 *
 * @author zouyaowen
 * @date 2020-06-22
 */
@RestController
@Slf4j
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService userService;

    @PostMapping("/add")
    public void addUser(UserDTO userDTO) {
        userService.addUser(userDTO);
    }

    @GetMapping("/id/{id}")
    public UserVO getById(@PathVariable Long id) {
        return userService.findUser(id);
    }

    @GetMapping("/name/{userName}")
    public UserVO getByName(@PathVariable String userName) {
        return userService.findUser(userName);
    }


}
